﻿@model Nop.Web.Models.Common.TaxTypeSelectorModel
@using Nop.Core.Domain.Tax
@if (Model.Enabled)
{
    var taxTypes = new List<SelectListItem>();
    taxTypes.Add(new SelectListItem()
    {
        Text = T("Tax.Inclusive").Text,
        Value = ((int)TaxDisplayType.IncludingTax).ToString(),
        Selected = Model.CurrentTaxType == TaxDisplayType.IncludingTax
    });
    taxTypes.Add(new SelectListItem()
    {
        Text = T("Tax.Exclusive").Text,
        Value = ((int)TaxDisplayType.ExcludingTax).ToString(),
        Selected = Model.CurrentTaxType == TaxDisplayType.ExcludingTax
    });
    
    @Html.DropDownList("customerTaxType", taxTypes)
    
    <script type="text/javascript">
        $(document).ready(function () {
            $("#customerTaxType").change(onTaxTypeChanged);
        });

        function onTaxTypeChanged() {
            var selectedTaxType = document.getElementById('customerTaxType');
            var selectedTaxTypeId = selectedTaxType.options[selectedTaxType.selectedIndex].value;
            var changeTaxTypeActionUrl = '@Url.Action("TaxTypeSelected", "Common", new { customerTaxType = "taxtypeplaceholder" })';
            changeTaxTypeActionUrl = changeTaxTypeActionUrl.replace("taxtypeplaceholder", selectedTaxTypeId);
            setLocation(changeTaxTypeActionUrl);
        }
    </script>
}